fun main() {
    val result = listOf(3,2,1).first().let {
        it*it
    }
    println(result)

    //等于
    val firstElement = listOf(3,2,1).first()
    val result01 = firstElement * firstElement
    println(result01)

    println(formatGreeting("jack"))
    println(formatGreeting2("rose"))
}

fun formatGreeting(guestName:String?): String {
    return guestName?.let{
        "welcome, $it."
    }?:"what's your name"
}

fun formatGreeting2(guestName: String?):String {
    return if(guestName != null) {
        "welcome, $guestName."
    } else {
        "what's your name"
    }
}